home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / nannws36.zip / UDF.PRG < prev   
Text File  |  1989-05-01  |  1KB  |  61 lines

  1. * Program: UDF.prg
  2. * Author:  Don L. Powells
  3. * Version: Clipper Summer '87
  4. * Note(s): Two samples of User-Defined Functions (UDFs).
  5. *
  6. * Copyright (c) 1988, 1989 Nantucket Corp.  All Rights Reserved.
  7.  
  8.  
  9. * Saycenter()
  10. * Centers a string on a given row.
  11. * Usage: Saycenter(row#, expC)
  12. *
  13. FUNCTION Saycenter
  14. PARAMETERS trow, in_string
  15. IF LEN(in_string) >= 80
  16.    @ trow, 0 SAY in_string
  17. ELSE
  18.    @ trow, (80 - LEN(in_string))/2 SAY in_string
  19. ENDIF
  20. RETURN (.T.)
  21.  
  22.  
  23. * Dupcheck()
  24. * Checks for the existence of the specified value in specified
  25. * file and index, and returns a true if the value is found.
  26. *
  27. FUNCTION Dupcheck
  28. PRIVATE mvalue, mfile, mntx, mntxkey
  29.  
  30. * Save the current workarea number
  31. currarea = SELECT()
  32.  
  33. * Check for the existence of the database
  34. IF FILE(mfile + ".dbf")
  35.    * Select or open the database and index files.
  36.    IF SELECT(mfile) = 0
  37.       * Go to next available workarea.
  38.       SELECT 0
  39.       USE (mfile)
  40.       IF FILE(mntx + ".ntx")
  41.          SET INDEX TO (mntx)
  42.       ELSE
  43.          * Create the index if it does not exist.
  44.          INDEX ON (mntxkey) TO (mntx)
  45.       ENDIF
  46.    ELSE
  47.       * Save the current workarea and select the new one.
  48.       wkarea = SELECT(mfile)
  49.       SELECT (wkarea)
  50.    ENDIF
  51.    currec = RECNO()
  52.    SEEK mvalue
  53.    retval = FOUND()
  54.    GO currec
  55. ELSE
  56.    retval = .F.
  57. ENDIF
  58. RETURN(retval)
  59.  
  60. * EOP: UDF.prg
  61.